const { MongoClient } = require('mongodb');
const config = require('./config');

let db, imageCollection, tagCollection, bookmarkCollection, folderCollection;

exports.connect = async () => {
    const client = await MongoClient.connect(config.mongoUrl);
    db = client.db(config.dbName);
    imageCollection = db.collection('images');
    tagCollection = db.collection('tags');
    bookmarkCollection = db.collection('bookmarks');
    folderCollection = db.collection('folders');
};

exports.getImageCollection = () => imageCollection;
exports.getTagCollection = () => tagCollection;
exports.getBookmarkCollection = () => bookmarkCollection;
exports.getFolderCollection = () => folderCollection;